#-*- coding: utf-8 -*-
from django.http import JsonResponse
from account.models import Account

def require_login(func):
    def wrapper(request, *args, **kwargs):
        account_id = request.session.get('account_id')
        account = Account.objects.filter(id=account_id).first()
        if not account:
            return JsonResponse({'code': -1, 'msg': '请先登录'})
        request.account = account
        return func(request, *args, **kwargs)
    return wrapper
        